package com.welab.springcloud.demo.order.controller;

import com.welab.springcloud.demo.dto.Order;
import com.welab.springcloud.demo.dto.ResponseResult;
import com.welab.springcloud.demo.order.service.OrderService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class OrderController {

    @Resource
    OrderService orderService;

    @GetMapping("/getUserOrder/{userId}")
    @ResponseBody
    public ResponseResult<List<Order>> getUserOrder(@PathVariable("userId") Integer userId) {
        return ResponseResult.success(orderService.getUserOrder(userId));
    }

    @PostMapping("/order/save")
    @ResponseBody
    public ResponseResult<List<Order>> orderSave(@RequestParam Integer userId) {
        orderService.orderSave(userId);
        return ResponseResult.success(null);
    }
}
